package en.edu.scau.cmi.zhanzhiyong.carpter07;

interface ComputeAverage{
	public double average(double a,double b);
}

class A implements ComputeAverage{
	public double average(double a,double b) {
		double aver = 0;
		aver =(a+b)/2;
		return aver;
	}
}

class B implements ComputeAverage{
	public double average(double a,double b) {
		double aver = 0;
		aver = Math.sqrt(a*b);
		return aver;
	}
}

public class Example7_3 {
	
	public static void main(String args[]) {
		ComputeAverage computer;
		double a = 11.23, b = 22.78;
		computer = new A();
		double result = computer.average(a, b);
		System.out.println(result);
		
		computer = new B();
		result = computer.average(a, b);
		System.out.println(result);
		
	}
}
